package com.zty.xiaomi.server.Service.Evidence;

import com.zty.xiaomi.server.Entity.Evidence.Evidence;
import com.zty.xiaomi.server.Mapper.EvidenceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.io.IOException;
import java.util.List;
@Service
@Transactional
public class EvidenceServiceImp implements EvidenceService{

    @Autowired
    private EvidenceMapper evidenceMapper;

    @Override
    public List<Evidence> getEvidenceByTribunalId(int tribunal_id) throws IOException {
        return evidenceMapper.getEvidenceByTribunalId(tribunal_id);
    }

    @Override
    public int addEvidenceByTribunalId(Evidence evidence) throws IOException {
        int num = evidenceMapper.addEvidenceByTribunalId(evidence);
        if (num != 1) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        return num;
    }
}
